<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.min.js"></script>
</head>

<body>
    <div id="app">
        <h2>计数器：{{count}}</h2>
        <input type="button" value="点我+1" @click="count++">
    </div>
</body>
<script>
    var VM = new Vue({
        el: "#app",
        data: {
            count: 1,
        },
        watch: {
            //检测属性值的变化
            count: function(nval, oval) {
                alert("计数器变化：" + oval + "变为" + nval);
            }
        },
    })
</script>

</html>